/*
 * FVoronoi.cpp
 *
 *  Created on: May 13, 2012
 *      Author: marchi
 */

#include "FVoronoi.h"
struct VolAreaInd{
	double Vol,area;
	int n;
	int Type;
};
class ContactSolute{
public:
	bool operator()(VolAreaInd x){return (x.area == 0.0);}
};
class Solute{
public:
	bool operator()(VolAreaInd x){return x.Type != Slt;}
};
class Solvent{
public:
	bool operator()(VolAreaInd x){return x.Type != Sol;}
};

FVoronoi::FVoronoi(int n, const vector<string> & s, bool bH): Voronoi(){
	nr=n;
	Vol=new double [nr];
	Neighs=new vector<int> [nr];
	Surface=new vector<double> [nr];
	label=new string [nr];
	types=new int [nr];

	for(int i=0;i<nr;i++){
		label[i]=s[i];
		if(bH || label[i].compare(0,1,h,0,1)) cindex.push_back(i);
	}
}
std::ofstream & operator<<(std::ofstream & fout , FVoronoi  & y){
	vector<VolAreaInd> tmp(y.nresid);

	for(int i=0;i<y.nresid;i++){
		tmp[i].Vol=y.Vols[i]*1000.0;
		tmp[i].area=y.area[i][0]*100.0;
		tmp[i].n=i+1;
		tmp[i].Type=y.getTypesRes(i);
	}
	vector<VolAreaInd> tmp0(tmp);
	tmp0.erase(std::remove_if(tmp0.begin(),tmp0.end(),Solute()),tmp0.end());
	tmp.erase(std::remove_if(tmp.begin(),tmp.end(),Solvent()),tmp.end());
	tmp.erase(std::remove_if(tmp.begin(),tmp.end(),ContactSolute()),tmp.end());

	fout << " Slt Vols " << tmp0.size() << endl;
	for(unsigned int i=0;i<tmp0.size();i++){
		fout << tmp0[i].n << " " << tmp0[i].Vol<< " "  <<  endl;
	}
	fout << " Solv Vols " << tmp.size() << endl;
	for(unsigned int n=0;n<tmp.size();n++){
		fout << n << " " << tmp[n].n << " " << tmp[n].Vol <<  endl;
	}
	return fout;
}
FVoronoi::~FVoronoi() {
	// TODO Auto-generated destructor stub
}

